package jtk.project4.fleet.screen.addFluidConsumed;

/*
* Author : Rio Dermawan 
* Date Created : 1-April-2011
* Date Modified : 6-April-2011
* Version : 1.1
* */

import java.sql.SQLException;

import jtk.project4.fleet.FleetModel;
import jtk.project4.fleet.domain.Fluids;
import jtk.project4.fleet.event.AddFluidConsumedEvent;
import jtk.project4.fleet.screen.addEditFuelEntry.AddEditFuelEntryView;
import nl.coderight.jazz.Controller;

public class AddFluidConsumedController extends Controller{
	private FleetModel fleetModel;
	private AddFluidConsumedView addFluidConsumedView;

	public void handleEvent(AddFluidConsumedEvent evt) throws SQLException {
		Fluids fluids = fleetModel.getFluids();
		switch (evt.getType()) {
		case SAVE:
			System.out.println(fluids.getNotes());
			fleetModel.insertFluids(fluids);
			break;
		default:
			propagateEvent(evt);
			break;
		}
	}
	
	@Override
	public void execute() {
		fleetModel = (FleetModel) getModel();
		addFluidConsumedView = new AddFluidConsumedView();
		setView(addFluidConsumedView);
		showView();
	}

}
